package snippets;

import java.util.*;
import java.lang.reflect.*;

public class AllFieldsSnippet {
    
    public static void main( String[] args ) {
	Object obj = new Object();
	//start extract AllFieldsSnippet

	Class cls = obj.getClass();
	List accum = new LinkedList();
	while (cls != null) {
	    Field[] f = cls.getDeclaredFields();
	    for (int i=0; i<f.length; i++) {
		accum.add(f[i]);
	    }
	    cls = cls.getSuperclass();
	}
	Field[] allFields = (Field[]) accum.toArray(new Field[accum.size()]);
	//stop extract AllFieldsSnippet
    }
}
